package com.yummy.common;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author yinbo
 */
public class DateUtils {
	public static Date stringToDate(String date, String pattern){
		SimpleDateFormat format = new SimpleDateFormat(pattern);
		Date toDate = null;
		try {
			toDate = format.parse(date);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return toDate;
	}

	public static  String dateToString(Date date,String pattern){
		SimpleDateFormat format = new SimpleDateFormat(pattern);
		String dateStr = format.format(date);
		return dateStr;
	}

	public static String getDate(String pattern){
		SimpleDateFormat format = new SimpleDateFormat(pattern);
		String date = format.format(new Date(System.currentTimeMillis()));
		return date;
	}
}